package mop.exception;

/**
 * Exception class to be thrown when a duplicate 
 * has been encountered
 * 
 * @invar none this is a exception
 * 
 * @author	 MOP Team 7
 */
public class IllegalDuplicationException extends Throwable 
{

	/**
	 * Initializes an IllegalDuplicationException with the passed name
	 * 
	 * @param name
	 *  the name that's duplicate
	 *  
	 * @effect sets the name
	 */
	public IllegalDuplicationException(String name)
	{
		this.setName(name);
	}
	
	/**
	 * return a error message that can be used by the gui
	 * 
	 * @return an error message describing the incorrect name
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("The following name already exists ! :: ");
		sb.append(this.name);
		return sb.toString();
		
	}
	
	 /**
	  * set the name
	  * 
	  * @param name
	  *  the name that's causing trouble
	  *  
	  * @post the name is set to the passed one
	  * 
	  */
	 private void setName(String name) 
	 {

		 this.name = name;
	 }
	
	/**
	 * weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * the name thats causing the problem
	 */
	private String name;
	
}